#ifndef _PAPA_BALL_SCENE_MANAGER_H_
#define _PAPA_BALL_SCENE_MANAGER_H_
#include <Windows.h>
#include <map>
#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include <OISMouse.h>

#include <SdkTrays.h>
#include <SdkCameraMan.h>

//#include "NuiWrap.h"
#include "Kinect.h"
#include "Scene.h"
#include "MenuManager.h"

using namespace Ogre;
using namespace OIS;

typedef std::map<Ogre::String,Ogre::FrameListener*> FrameListenerContainerType;
typedef std::map<Ogre::String,OIS::KeyListener*> KeyListenerContainerType;
typedef std::map<Ogre::String,OIS::MouseListener*> MouseListenerContainerType;

class PapaBallSceneManager: public Ogre::Singleton<PapaBallSceneManager>,public Ogre::FrameListener, public OIS::KeyListener, public OIS::MouseListener,public Ogre::WindowEventListener
{
public:
	PapaBallSceneManager();
	~PapaBallSceneManager();

	
	void setScene(std::string name);
	std::string getCurrentSceneName();
	void setup();
	void setupWindow();
	Scene* getScend(){return NULL;}

protected:

	void ChangeScene(Scene *scene);

	bool frameStarted(const FrameEvent& evt);
	bool frameRenderingQueued(const Ogre::FrameEvent& evt);
	bool frameEnded(const FrameEvent& evt);

	bool keyPressed( const KeyEvent &arg ) ;
	bool keyReleased( const KeyEvent &arg );		

	bool mouseMoved( const MouseEvent &arg ) ;
	bool mousePressed( const MouseEvent &arg, MouseButtonID id ) ;
	bool mouseReleased( const MouseEvent &arg, MouseButtonID id ) ;

	void windowResized(Ogre::RenderWindow* rw);
	void windowClosed(Ogre::RenderWindow* rw);

	void createFrameListener();
	void chooseSceneManager();
	void createViewports(void);
	void createCamera();


	Scene* m_current_scene;

	//OIS Input devices
	OIS::InputManager* mInputManager;
	OIS::Mouse*    mMouse;
	OIS::Keyboard* mKeyboard;

	Ogre::Root *mRoot;
	Ogre::SceneManager* mSceneMgr;
	Ogre::RenderWindow* mWindow;
	bool mCursorWasVisible;                  // was cursor visible before dialog appeared
	bool mShutDown;
	Ogre::Camera* mCamera;
	Ogre::Viewport* mViewport;
	OgreBites::SdkCameraMan* mCameraMan;
	MenuManager *mMenuMgr;
	SceneEvnArgs mSceneEvn;

//	OIS::NuiWrap * pNui;

	FrameListenerContainerType mFrameListeners;
	KeyListenerContainerType mKeyListeners;
	MouseListenerContainerType mMouseListeners;

	FrameListenerContainerType mGlobalFrameListeners;
	KeyListenerContainerType mGlobalKeyListeners;
	MouseListenerContainerType mGlobalMouseListeners;
private:
	bool bChangeScene;
	std::string SwitchSceneName;
};

#endif